using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIHealthBar : MonoBehaviour
{
    // 需要导入UnityEngine.UI库才有Image
    public Image mask;
    float originalSize;

    // 单例模式
    public static UIHealthBar instance { get; private set; }

    // 任务系统
    public bool hasTask; // 当前是否有任务
    public bool ifCompleteTask; // 当前是否完成任务
    public int fixedNum;

    private void Awake()
    {
        instance = this;
    }

    // Start is called before the first frame update
    void Start()
    {
        originalSize = mask.rectTransform.rect.width;
    }

    // Update is called once per frame
    void Update()
    {

    }

    // 设置当前UI血条的显示值
    public void setValue(float fillPercent)
    {
        mask.rectTransform.SetSizeWithCurrentAnchors(
            RectTransform.Axis.Horizontal,
            originalSize * fillPercent);
    }

}
